﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>权限管理 - 功能实体管理</title>

  <#include "/pages/include/head.ftl" />
	<#import "/pages/import/images.ftl" as img />
	<style>
	</style>
	<script>
	</script>
</head>

<body>

<#assign model="role"/>
<#assign gridId="${model + 'Grid'}">
<@s.url id="indexurl" action="${model}Grid-index" namespace="/widgets"/>
<@s.url id="showurl" action="${model}Grid-show" namespace="/widgets"/>
<@s.url id="deleteurl" action="${model}Grid-delete" namespace="/widgets"/>

<div class="page-top-bar">
<ul class="path">权限管理<span>&gt;</span>角色管理</ul>
</div>

<!--工具栏 start-->
<div class="function-bar">
<ul class="form-function">
    <li><a href="add.action" onfocus="this.blur()" target="main"><img src="${contextPath}/images/ico16/ico-add.gif" alt="新建" border="0" title="新建" /></a></li>
    <li><a id="btn-edit" href="javascript:void(0)"><img src="${contextPath}/images/ico16/ico-edit.gif" alt="修改" title="修改" /></a></li>
    <li><a id="btn-delete" href="javascript:void(0)"><img src="${contextPath}/images/ico16/ico-cancel.gif" alt="删除" title="删除" /></a></li>
    <li><a id="btn-setstatus" href="javascript:void(0)"><img src="${contextPath}/images/ico16/ico_commission_16.gif" alt="设置激活状态" border="0" title="设置激活状态" />状态设置</a></li>
    <li><a href="javascript:void(0)"><img src="${contextPath}/images/ico16/ico-introduction.gif" alt="导入" title="导入" /><span></span></a></li>
    <li><a href="javascript:void(0)"><img src="${contextPath}/images/ico16/ico-derivation.gif" alt="导出" title="导出" /><span></span></a></li>
</ul>
</div>
<!--工具栏 end-->

<@rw.gridToolbar grid="roleGrid"/>

<div class="list-container">
<@rw.gridForm id="searchform" grid="roleGrid">
<div class="list-search">
<ul>
<li><label for="">角名名称：</label><input name="criteria.name" type="text" class="input-common input-word-10" /></li>
	<li>
	  <label for="">状态：</label>
	  <select id="" name="criteria.status" class="select-word-10">
	    <option value="">全部</option>
        <option value="ENABLED">激活</option>
        <option value="DISABLED">停用</option>
	  </select></li>
	<li>
	  <label for="">业务系统：</label>
	  <select id="" name="" class="select-word-10">	
	  <option>全部</option>
	  </select>
	  </li>
<li class="search-btn-area">
      <div class="btn-order">
        <ul>
          <li class="left-normal" id="btn1_11"></li>
          <li class="middle-normal" id="submit"><img src="${contextPath}/images/ico16/ico-search.gif" alt="查询" />查 询</li>
          <li class="right-normal" id="btn1_13"></li>
       </ul>
      </div>
	</li>
</ul>
</div>
</@rw.gridForm>

<!-- grid start -->

<@rw.grid 
	id="${gridId}" 
	caption="功能角色列表" 
	dataType="json"
	href="%{indexurl}"
	pager="true" 
	gridModel="gridModel"
	rowList="10,15,20"
	rowNum="10"
	rownumbers="true"
	multiselect="true"
	width="960"
	onGridCompleteTopics="grid-complete">
	<@sj.gridColumn name="id" 			index="id"			title="序号" 		hidden="true"	sortable="false"/>
	<@sj.gridColumn name="name" 		index="name"		title="功能角色名称" 	formatter="showlink" formatoptions="{baseLinkUrl:'%{showurl}'}" />
	<@sj.gridColumn name="description" 		index="description"		title="备注" 	sortable="false"/>
	<@sj.gridColumn name="id" index="id"	title="操作"		formatter="addpermissionUrl" 	sortable="false"/>
	<@sj.gridColumn name="status"		index="status"		title="状态"		formatter="icon" sortable="false"/>
</@rw.grid>

<div id="grid" class="border-lbr"></div>
<!-- grid end -->
</div>

 <script>
$(function(){
	$("#${gridId}").enhanceGrid();
	$("#btn-delete").click(function(){
	   top.$.messagebox({type:'ask',
	                     msg:'确定要删除选中的记录吗？',
	                     title:'统一授权平台管理系统 ',
	                     fn:function(button, msg){
	                        if(button.index=='0'){
	                          var selectedId = $("#${gridId}").jqGrid('getGridParam','selrow');
		                      $("#${gridId}").publish("grid-delete", {url: "${deleteurl}"});
	                        }
	                     }
	                     });
	});
	// TODO: 订阅 "grid-delete-success"，通知tree重新加载
	$("#btn-edit").click(function(){
		var selectedId	= getSelectId();
		if(selectedId != null){
		  var url = "edit.action?id="+selectedId; 
		  window.open(url,"main","");
		}
	});
	
	$("#btn-setstatus").click(function(){
	    var selectedId	= getSelectId();
	    if(selectedId != null){
			top.windowOpen('${contextPath}/role/setStatus.action?id='+selectedId, 'pop01', '统一授权平台管理系统 ', 180,400);
		}
	});
	
	function getSelectId(){
	   var selectedId	= $("#${gridId}").jqGrid('getGridParam','selarrrow');
		
		 if(selectedId.length>1){
             alert("当前操作只能选择一条记录");
             return null;
           }
           if(selectedId.length==0){
             alert("请选中你所需要操作的记录");
             return null;
           }
           
           return selectedId;
	}
});
</script>
<script>$(function(){ $("#${gridId}").externalSearch("#searchform"); });</script>

<script type="text/javascript">			
$(function(){
	$("#tree").subscribe("tree-nodeSelect", function(event, data){
		data['criteria.parent.id'] = data.id;
		delete data.id;
		$("#${gridId}").publish("grid-filter", data);
	});
});


function popAddpermissionPanel(id){
  if(id=='' || id=='undefined'){
     alert("error");
     return;
  }
  top.windowOpen('${contextPath}/role/preAddpermissions.action?id='+id, 'pop01', '统一授权平台管理系统', 530,300);
}

function addpermissionUrl(cellvalue, options, rowdata){
    var id = cellvalue;
	return "<a href=javascript:void(0); onclick=popAddpermissionPanel('"+id+"')>权限分配</a>";
}
</script>
 </body>
</html>

